home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / e / gencodee_v21.lha / GenCodeE / E / Localized_DemoGenCodeE30b / DemoGenCodeE.em < prev    next >
Text File  |  1994-11-15  |  7KB  |  196 lines

  1. OPT OSVERSION = 37
  2.  
  3.  
  4. /*/////////////////////////////////////////////////////////////////////////////
  5. ///////////////////////////////////////////////////////////// Macro files /////
  6. ///////////////////////////////////////////////////////////////////////////////
  7. MACROS 'MUI.pma'
  8. */
  9.  
  10.  
  11. ->/////////////////////////////////////////////////////////////////////////////
  12. ->////////////////////////////////////////////////////// External modules /////
  13. ->/////////////////////////////////////////////////////////////////////////////
  14. MODULE 'locale'
  15. MODULE 'muimaster' , 'libraries/mui'
  16. MODULE 'utility/tagitem' , 'utility/hooks'
  17. MODULE 'tools/boopsi' , 'tools/installhook'
  18. MODULE 'icon'
  19.  
  20. MODULE '*GUI'
  21. MODULE '*Locale'
  22.  
  23.  
  24. ->/////////////////////////////////////////////////////////////////////////////
  25. ->/////////////////////////////////////////// Global variable definitions /////
  26. ->/////////////////////////////////////////////////////////////////////////////
  27. DEF dgce    :    PTR TO app_obj            -> look at GUI.em for "app_obj" object
  28. DEF cat        :    PTR TO catalog_DemoGenCodeE    -> look at Locale.e for "catalog_DemoGenCodeE" object
  29. DEF string_var    :    PTR TO CHAR            -> used by a notification (see GUI.em, lines 49 and 155)
  30.  
  31.  
  32. ->/////////////////////////////////////////////////////////////////////////////
  33. ->//////////////////////////////////////////////////////// Main Procedure /////
  34. ->/////////////////////////////////////////////////////////////////////////////
  35. PROC main() HANDLE
  36.  
  37.     DEF running = TRUE , result_domethod , signal
  38.     DEF arexx : app_arexx , display : app_display
  39.     DEF change_text_hook : hook , arexx_commands : PTR TO mui_command
  40.     DEF icon = NIL
  41.  
  42.         -> localization init
  43.     localebase := OpenLibrary( 'locale.library' , 0 )
  44.     NEW cat.create()    -> see Locale.e
  45.     cat.open( NIL , NIL )    -> see Locale.e
  46.  
  47.         -> needed libraries and icon init
  48.     IF ( muimasterbase := OpenLibrary( 'muimaster.library' , MUIMASTER_VMIN ) ) = NIL THEN Throw( "LIB" , "muim" )
  49.     IF ( iconbase := OpenLibrary( 'icon.library' , 0 ) ) THEN icon := GetDiskObject( 'PROGDIR:DemoGenCodeE' ) ELSE Throw( "LIB" , "icon" )
  50.  
  51.         -> exported variables init
  52.     string_var := cat.msg_String_Variable_Put.getstr()
  53.  
  54.         -> MUI GUI init
  55.             -> in GUI.em line 22, you can see the declaration of "app_display" object
  56.             -> each field of this object correspond to a hook function declared in MUIBuilder
  57.             -> in the present case, there is only the "button_pressed" hook function (see GUI.em line 167)
  58.     installhook( display.button_pressed , {button_pressed} )
  59.  
  60.         -> ARexx init
  61.             -> for ARexx init you must fill an "app_arexx" object defined in GUI.em line 17
  62.             -> this object gets 2 fields : one for the commands and one for the arexx error hook function
  63.     installhook( change_text_hook , {change_text} )
  64.     arexx.commands := NEW arexx_commands[ 2 ]
  65.     arexx.commands[].mc_name := 'change_text'
  66.     arexx.commands[].mc_template := ''
  67.     arexx.commands[].mc_parameters := 0
  68.     arexx.commands[].mc_hook := change_text_hook
  69.     installhook( arexx.error , {arexx_error} )
  70.  
  71.         -> MUI application creation
  72.             -> for this you call the create method (see GUI.em line 57) on the "app_obj" object
  73.             -> to this method, you must give the "app_display" object
  74.             -> and if you want (not obliged), you can give an icon, the "app_arexx" object and a menu object (obsolete)
  75.     NEW dgce
  76.     IF dgce.create( display , icon , arexx ) = NIL THEN Throw( "MUI" , Mui_Error() )
  77.     dgce.init_notifications( display )
  78.  
  79.         -> Main loop
  80.     WHILE running
  81.  
  82.         result_domethod := domethod( dgce.app , [ MUIM_Application_Input , {signal} ] )
  83.         SELECT result_domethod
  84.  
  85.             CASE ID_BUTTON_PRESSED    -> see GUI.em line 42 for the definition of this ID
  86.  
  87.                 set( dgce.tx_result , MUIA_Text_Contents , cat.msg_Modified_ID_Returned.getstr() )
  88.  
  89.             CASE MUIV_Application_ReturnID_Quit
  90.  
  91.                 running := FALSE
  92.  
  93.         ENDSELECT
  94.  
  95.         IF ( signal AND running ) THEN Wait( signal )
  96.  
  97.     ENDWHILE
  98.  
  99. EXCEPT DO
  100.  
  101.     SELECT exception
  102.  
  103.         CASE "LIB"
  104.  
  105.             SELECT exceptioninfo
  106.  
  107.                 CASE "muim"
  108.  
  109.                     error_simple( cat.msg_Missing_Muimaster_Library.getstr() )
  110.  
  111.                 CASE "icon"
  112.  
  113.                     error_simple( cat.msg_Missing_Icon_Library.getstr() )
  114.  
  115.             ENDSELECT
  116.  
  117.         CASE "MEM"
  118.  
  119.             error( cat.msg_Not_Enough_Memory.getstr() )
  120.  
  121.         CASE "MUI"
  122.  
  123.             SELECT exceptioninfo
  124.  
  125.                 CASE MUIE_OutOfMemory
  126.  
  127.                     error_simple( cat.msg_Not_Enough_Memory.getstr() )
  128.  
  129.                 CASE MUIE_OutOfGfxMemory
  130.  
  131.                     error_simple( cat.msg_Not_Enough_Chip_Memory.getstr() )
  132.  
  133.                 CASE MUIE_MissingLibrary
  134.  
  135.                     error_simple( cat.msg_Missing_Library.getstr() )
  136.  
  137.                 CASE MUIE_NoARexx
  138.  
  139.                     error_simple( cat.msg_Arexx_Port.getstr() )
  140.  
  141.                 DEFAULT
  142.  
  143.                     error_simple( cat.msg_Internal_Problem.getstr() )
  144.  
  145.             ENDSELECT
  146.  
  147.     ENDSELECT
  148.  
  149.     IF dgce            THEN dgce.dispose()
  150.     IF icon            THEN FreeDiskObject( icon )
  151.     IF iconbase        THEN CloseLibrary( iconbase )
  152.     IF muimasterbase    THEN CloseLibrary( muimasterbase )
  153.     cat.close()
  154.     IF localebase        THEN CloseLibrary( localebase )
  155.  
  156. ENDPROC
  157.  
  158.  
  159. ->/////////////////////////////////////////////////////////////////////////////
  160. ->/////////////////// Prints an error message with an intuition requester /////
  161. ->/////////////////////////////////////////////////////////////////////////////
  162. PROC error_simple( message : PTR TO CHAR ) IS EasyRequestArgs(    NIL , [ 20 , 0 ,
  163.                                     cat.msg_DGCE_Error.getstr() ,
  164.                                     message ,
  165.                                     cat.msg_Simple_OK.getstr() ] , NIL , NIL )
  166.  
  167.  
  168. ->/////////////////////////////////////////////////////////////////////////////
  169. ->///////////////////////// Prints an error message with an MUI requester /////
  170. ->/////////////////////////////////////////////////////////////////////////////
  171. PROC error( message : PTR TO CHAR ) IS Mui_RequestA(    dgce.app ,
  172.                             dgce.wi_the_window ,
  173.                             NIL ,
  174.                             cat.msg_DGCE_Error.getstr() ,
  175.                             cat.msg_OK.getstr() ,
  176.                             message ,
  177.                             NIL )
  178.  
  179.  
  180. ->/////////////////////////////////////////////////////////////////////////////
  181. ->///////// Hook function called each time bt_call_hook button is pressed /////
  182. ->/////////////////////////////////////////////////////////////////////////////
  183. PROC button_pressed( hook , obj , msg ) IS set( dgce.tx_result , MUIA_Text_Contents , cat.msg_Modified_By_Hook.getstr() )
  184.  
  185.  
  186. ->/////////////////////////////////////////////////////////////////////////////
  187. ->///////////////////// Hook function called by ARexx command change_text /////
  188. ->/////////////////////////////////////////////////////////////////////////////
  189. PROC change_text( hook , obj , msg ) IS set( dgce.tx_result , MUIA_Text_Contents , cat.msg_Modified_By_Arexx.getstr() )
  190.  
  191.  
  192. ->/////////////////////////////////////////////////////////////////////////////
  193. ->//////////////////////// Hook function called by ARexx in case of error /////
  194. ->/////////////////////////////////////////////////////////////////////////////
  195. PROC arexx_error( hook , obj , msg ) IS error_simple( cat.msg_Unknown_ARexx_Command.getstr() )
  196.